-
Notifications
You must be signed in to change notification settings - Fork 550
Fix ignore comment handling for multiple traits in a single file #4804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| use Foo; | ||
| use Baz; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in phpstan/phpstan#13945 its reported that the errors emitted depend on the order of this use-statements.
I think it would be good than, to additional test this with use in different order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test case
| $linesToIgnore[$scope->getFileDescription()] = $this->getLinesToIgnoreFromTokens([$traitNode]); | ||
| $fileDescription = $scope->getFileDescription(); | ||
| $linesToIgnore[$fileDescription] ??= []; | ||
| $linesToIgnore[$fileDescription] += $this->getLinesToIgnoreFromTokens([$traitNode]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain what's happening here? $scope->getFileDescription() should be unique per trait usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value of $scope->getFileDescription() contains:
- File path where the trait is defined
- Name of the class which
uses the trait
It does not contain trait name, so is not necessarily unique when a file has two or more traits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, right!
|
Thank you very much! |
$linesToIgnoredata was not correctly gathered when:Closes phpstan/phpstan#13945